const assert = require('assert');
const BasicController = require('../BasicController.js');

module.exports = class extends BasicController {
  constructor(ctx) {
    super(ctx);
    assert(think.isFunction(this.model), 'this.model must be a function');
    this.MODEL = this.ctx.state.ApiInfo.model;
    this.params = {
      model: this.MODEL,
      data: this.post()
    };
  }
};

/**
 * @api {get} /richtext/richtext/get /get
 * @apiDescription 根据id查询富文本信息
 * @apiGroup richtext
 * @apiParam {String} id  富文本ID
 *
 *
 * @apiParamExample {string} 请求参数格式:
 *    ?id=dbbad191-7ca9-4629-b0b4-f7e84d7de31e
 *
 * @apiVersion 1.0.0
 * @apiErrorExample {json} 错误返回值:
 *{
 *   "code": 1001,
 *   "msg": {
 *      "id": "id can not be blank"
 *   }
 *}
 * @apiSuccessExample {json} 正确返回值:
 * {
 *  "code": 0,
 *  "msg": "",
 *  "data": {
 *      "id": "dbbad191-7ca9-4629-b0b4-f7e84d7de31e",
 *      "richtext": {
 *          "type": "Buffer",
 *          "data": [
 *               110,
 *              119,
 *              101,
 *              92,
 *              55,
 *              54,
 *              119,
 *              93,
 *              47,
 *              92,
 *              72
 *          ]
 *      },
 *      "relation_id": "12585252",
 *      "status": 1
 *  }
 * }
 */

/**
 * @api {delete} /richtext/richtext/del /del
 * @apiDescription 根据id删除富文本信息
 * @apiGroup richtext
 *
 * @apiParam {String} id  富文本id
 *
 *
 * @apiParamExample {object} 请求参数格式:
 *  {
 * id: dda33412-8e95-40f9-92f5-f01df8dd2d21,
 * }
 *
 * @apiVersion 1.0.0
 * @apiErrorExample {json} 错误返回值:
 * {
 * "code": 1001,
 * "msg": {
 *      "id": "id can not be blank"
 *  }
 * }
 * @apiSuccessExample {json} 正确返回值:
 * {
 *  "code": 0,
 *  "msg": "",
 *  "data": 1
 * }
 */

/**
 * @api {post} /richtext/richtext/edit /edit
 * @apiDescription 根据id查询修改富文本
 * @apiGroup richtext
 *
 * @apiParam {String} id 富文本id
 * @apiParam {String} [richtext] 富文本内容
 * @apiParam {String} [status] 富文本状态
 * @apiParam {String} [relation_id] 富文本所属项目id
 *
 *
 *
 * @apiParamExample {object} 请求参数格式:
 *  {
 *  id: 'dbbad191-7ca9-4629-b0b4-f7e84d7de31e',
 *  status: 0,
 *  relation_id: 'dbbad191-7ca9-4629-b0b4-f7e84d7de3ee',
 * }
 *
 * @apiVersion 1.0.0
 * @apiErrorExample {json} 错误返回值:
 * {
 * "code": 1001,
 * "msg": {
 *      "id": "id can not be blank"
 *  }
 * }
 * @apiSuccessExample {json} 正确返回值:
 *{
 *   "errno": 0,
 *   "errmsg": "",
 *   "data": 1
*}
*/

/**
 * @api {POST} /richtext/richtext/listall /listall
 * @apiDescription 获取全部富文本内容列表/根据条件获取富文本列表
 * @apiGroup richtext
 *
 * @apiParam {String} [id] 富文本ID
 * @apiParam {String} [relation_id] 富文本所属项目id
 * @apiParam {String} [status] 富文本状态
 *
 * @apiVersion 1.0.0
 * @apiErrorExample {json} 错误返回值:
 *     {
 *        "code": ,
 *        "msg": "获取失败",
 *        "error": {
 *        },
 *     }
 *
 * @apiSuccessExample {json} 正确返回值:
 * {
 *  "code": 0,
 *  "msg": "",
 *  "data": {
 *      "id": "dbbad191-7ca9-4629-b0b4-f7e84d7de31e",
 *      "richtext": {
 *          "type": "Buffer",
 *          "data": [
 *               110,
 *              119,
 *              101,
 *              92,
 *              55,
 *              54,
 *              119,
 *              93,
 *              47,
 *              92,
 *              72
 *          ]
 *      },
 *      "relation_id": "12585252",
 *      "status": 0
 *  }
 * }
 */

/**
 * @api {POST} /richtext/richtext/listpage /listpage
 * @apiDescription 获取全部富文本内容列表/根据条件分页获取富文本列表
 * @apiGroup richtext
 *
 * @apiParam {String} [id] 富文本ID
 * @apiParam {String} [relation_id] 富文本所属项目id
 * @apiParam {String} [status] 富文本状态
 * @apiParam {Number} [page] 页数
 * @apiParam {Number} [pageSize] 数据条数
 *
 *
 *  * @apiParamExample {post} Request-Example:
                 {
                   page:1,
                   pageSize:10,
                   status:0
                  }
 * @apiVersion 1.0.0
 * @apiErrorExample {json} 错误返回值:
 *     {
 *        "code": ,
 *        "msg": "获取失败",
 *        "error": {
 *        },
 *     }
 *
 * @apiSuccessExample {json} 正确返回值:
{
    "code": 0,
    "msg": "",
    "data": {
        "pageSize": 10,
        "current": 1,
        "pages": 1,
        "total": 4,
        "data": [
            {
                "id": "b049e7f9-ac87-4c9d-9c7b-0879870d6c2a",
                "richtext": {
                    "type": "Buffer",
                    "data": [
                        228,
                        189,
                        160,
                        229,
                        165,
                        189,
                        233,
                        187,
                        ......
 *              55,
 *              54,
 *              119,
 *              93,
 *              47,
 *              92,
 *              72
 *          ]
 *      },
 *      "relation_id": "12585252",
 *      "status": 0
 *  }
 * }
 */

/**
 * @api {POST} /richtext/richtext/add /add
 * @apiDescription 新增富文本
 * @apiGroup richtext
 *
 * @apiParam {String} relation_id 所属信息id
 * @apiParam {String} [richtext] 富文本内容
 * @apiParam {Number} [status] 富文本状态

 *
 * @apiVersion 1.0.0
 * @apiErrorExample {json} 错误返回值:
 * {
 *   "code": 1001,
 *  "msg": {
 *      "relation_id": "projrelation_idect_id can not be blank",
 *  }
 * }
 *
 * @apiSuccessExample {json} 正确返回值:
 * {
 *  "code": 0,
 *  "msg": "",
 *  "data": {
 *      "id": "ea6ccba8-f47d-4a0c-b54b-eef565f56829"
 *  }
 * }
 */
